home *** CD-ROM | disk | FTP | other *** search
/ Network Supervisor's Toolkit / Network Supervisor's Toolkit.iso / tools / lu62 / port / rconio.h < prev    next >
Text File  |  1996-07-10  |  10KB  |  439 lines

  1. /* k 0069    21/10/90    */
  2. /* k 0079    14/11/90    */
  3. /* k 0159     20/04/91    */
  4. /* k 0160    04/05/91    */
  5. /* k 0182    17/06/91    */
  6. /* k 0184       18/06/91        */
  7. /* k 0191    02/07/91    */
  8. /* k 0207    06/09/91    *//* betbut */
  9. /* k 0209    07/09/91    *//* move betbut to panal */
  10. /* k 0222    18/09/91    *//* Separation */
  11. /* k 0224       23/09/91        *//* ebss */
  12. /* k 0230       09/10/91        *//* assemble some data */
  13. /* k 0232    11/10/91    */
  14. #include <ebss.h>               /* @0224 */
  15. #if ((OS_TYPE==3) || (OS_TYPE==4))
  16. extern unsigned int adaptIO;
  17. #else
  18. /* @0209 */
  19. #endif
  20. #include <pconio.h>
  21. void movecursor(),c_dec();
  22. void pwindow(xx1,yy1,xx2,yy2)    /* @0182 */
  23. short xx1;    /* @0182 */
  24. short yy1;    /* @0182 */
  25. short xx2;    /* @0182 */
  26. short yy2;    /* @0182 */
  27.   {
  28.    px1=xx1;
  29.    py1=yy1;
  30.    px2=xx2;
  31.    py2=yy2;
  32.    pcurx=xx1;
  33.    pcury=yy1;
  34.    pxw=px2-px1+1;
  35.    pyw=py2-py1+1;
  36. #if (OS_TYPE==4)     /* @0184 */
  37.   begpt=videobuf;
  38. #else
  39.    begpt=(char *)0xb8000000;
  40. #endif
  41.    begpt+=((py1-1)*160+(px1-1)*2);
  42.   }
  43. void pclrscr()
  44.   {
  45.    short i,j;
  46.    char *pt;
  47.    pt=begpt;
  48.    for (i=0;i<pyw;i++)
  49.     {
  50.      for (j=0;j<pxw;j++)
  51.       {
  52.        *pt=' ';
  53.        pt++;
  54.        *pt=pattr;
  55.        pt++;
  56.       }
  57.      pt+=160-2*pxw;
  58.     }
  59.    pcurx=px1;
  60.    pcury=py1;
  61.    curpt=begpt;
  62.    movecursor(pcurx,pcury);
  63.   }
  64. void ptextattr(c)    /* @0182 */
  65. char c;    /* @0182 */
  66.   {
  67.    pattr=c;
  68.   }
  69. void ptextbackground(c)        /* @0182 */
  70. unsigned char c; /* @0182 */    /* @0191 */
  71.   {
  72.    pattr&=143;
  73.    pattr|=c*16;
  74.   }
  75. void ptextcolor(c)        /* @0182 */
  76. char c;        /* @0182 */
  77.   {
  78.    pattr&=240;
  79.    pattr|=c;
  80.   }
  81. #if (OS_TYPE==3)
  82.  
  83. int position ( ) {
  84. unsigned int x,y;
  85.  outp (baseport,0x0f);
  86.  x=inp(baseport+1);
  87.  outp (baseport,0x0e);
  88.  y=inp(baseport+1);
  89.  return ( (y << 8) + x );
  90. }
  91.  
  92. void mygotoxy (unsigned int posit) {
  93. unsigned char b1=posit & 0xFF;
  94. unsigned char b2=posit >> 8;
  95.  outp (baseport,0x0f);
  96.  outp (baseport+1,b1);
  97.  outp (baseport,0x0e);
  98.  outp (baseport+1,b2);
  99. }
  100.  
  101. short pwherex()
  102.  {
  103. unsigned int x,y;
  104.  outp (baseport,0x0f);
  105.  x=inp(baseport+1);
  106.  outp (baseport,0x0e);
  107.  y=inp(baseport+1);
  108.  x=(y << 8) + x;
  109.  return (x%80+2-px1);
  110. }
  111.  
  112. short pwherey()
  113.  {
  114. unsigned int x,y;
  115.  outp (baseport,0x0f);
  116.  x=inp(baseport+1);
  117.  outp (baseport,0x0e);
  118.  y=inp(baseport+1);
  119.  x=(y <<8) + x;
  120.  return (x%80+2-px1);
  121. }
  122.  
  123.  
  124. void movecursor(short x,short y) /* physical coordinates */
  125.  {
  126.    mygotoxy (80*y + x - 81);
  127.    curpt=(char *)0xb8000000;
  128.    curpt+=((y-1)*160+(x-1)*2);
  129.  }
  130. #elif (OS_TYPE==4)
  131. #define IN_ON_PORT    1
  132. #define OUT_ON_PORT    0
  133. int position ( ) {
  134. struct port_io_arg depoz;
  135.  depoz.args[0].dir=OUT_ON_PORT;
  136.  depoz.args[0].port=baseport;
  137.  depoz.args[0].data=0x0f;
  138.  depoz.args[1].dir=IN_ON_PORT;
  139.  depoz.args[1].port=baseport+1;
  140.  depoz.args[2].dir=OUT_ON_PORT;
  141.  depoz.args[2].port=baseport;
  142.  depoz.args[2].data=0x0e;
  143.  depoz.args[3].dir=IN_ON_PORT;
  144.  depoz.args[3].port=baseport+1;
  145.  
  146.  ioctl (0,adaptIO,&depoz);
  147.  return (((unsigned)depoz.args[3].data << 8) + (unsigned)depoz.args[1].data );
  148. }
  149.  
  150. void mygotoxy (unsigned int posit) {
  151. struct port_io_arg depoz;
  152. unsigned char b1=posit & 0xFF;
  153. unsigned char b2=posit >> 8;
  154.  depoz.args[0].dir=OUT_ON_PORT;
  155.  depoz.args[0].port=baseport;
  156.  depoz.args[0].data=0x0f;
  157.  depoz.args[1].dir=OUT_ON_PORT;
  158.  depoz.args[1].port=baseport+1;
  159.  depoz.args[1].data=b1;
  160.  depoz.args[2].dir=OUT_ON_PORT;
  161.  depoz.args[2].port=baseport;
  162.  depoz.args[2].data=0x0e;
  163.  depoz.args[3].dir=OUT_ON_PORT;
  164.  depoz.args[3].port=baseport+1;
  165.  depoz.args[3].data=b2;
  166.  ioctl (0,adaptIO,&depoz);
  167. }
  168.  
  169. short pwherex()
  170.  {
  171.  int x;
  172. struct port_io_arg depoz;
  173.  depoz.args[0].dir=OUT_ON_PORT;
  174.  depoz.args[0].port=baseport;
  175.  depoz.args[0].data=0x0f;
  176.  depoz.args[1].dir=IN_ON_PORT;
  177.  depoz.args[1].port=baseport+1;
  178.  depoz.args[2].dir=OUT_ON_PORT;
  179.  depoz.args[2].port=baseport;
  180.  depoz.args[2].data=0x0e;
  181.  depoz.args[3].dir=IN_ON_PORT;
  182.  depoz.args[3].port=baseport+1;
  183.  
  184.  ioctl (0,adaptIO,&depoz);
  185.  x=((unsigned)depoz.args[3].data << 8) + (unsigned)depoz.args[1].data;
  186.   
  187.  return (x%80+2-px1);
  188. }
  189. short pwherey()
  190.  {
  191.  int x;
  192.  struct port_io_arg depoz;
  193.  depoz.args[0].dir=OUT_ON_PORT;
  194.  depoz.args[0].port=baseport;
  195.  depoz.args[0].data=0x0f;
  196.  depoz.args[1].dir=IN_ON_PORT;
  197.  depoz.args[1].port=baseport+1;
  198.  depoz.args[2].dir=OUT_ON_PORT;
  199.  depoz.args[2].port=baseport;
  200.  depoz.args[2].data=0x0e;
  201.  depoz.args[3].dir=IN_ON_PORT;
  202.  depoz.args[3].port=baseport+1;
  203.  
  204.  ioctl (0,adaptIO,&depoz);
  205.  x=((unsigned)depoz.args[3].data <<8) + (unsigned)depoz.args[1].data;
  206.  
  207.  return (x/80+2-py1);
  208. }
  209. void movecursor(short x,short y) /* physical coordinates */
  210.  {
  211.    mygotoxy (y*80 + x - 81);
  212.   curpt=videobuf;
  213.    curpt+=((y-1)*160+(x-1)*2);
  214.  }
  215. #else
  216.  
  217. #if ((OVL_TYPE==1)&&(RESIDENT!=1))
  218.  short pwherex()
  219.  {
  220.    reg.h.ah=3;
  221.    reg.h.bh=0;
  222.    Res_int86(0x10,®,®);
  223.    return (reg.h.dl+2-px1);
  224.  }
  225. short pwherey()
  226.  {
  227.    reg.h.ah=3;
  228.    reg.h.bh=0;
  229.    Res_int86(0x10,®,®);
  230.    return (reg.h.dh+2-py1);
  231.  }
  232. #else
  233.  short pwherex()
  234.  {
  235.    reg.h.ah=3;
  236.    reg.h.bh=0;
  237.    int86(0x10,®,®);
  238.    return (reg.h.dl+2-px1);
  239.  }
  240. short pwherey()
  241.  {
  242.    reg.h.ah=3;
  243.    reg.h.bh=0;
  244.    int86(0x10,®,®);
  245.    return (reg.h.dh+2-py1);
  246.  }
  247. #endif
  248. #if ((OVL_TYPE==1)&&(RESIDENT!=1))
  249. void mygotoxy (unsigned int posit) {
  250. unsigned char b1=posit & 0xFF;
  251. unsigned char b2=posit >> 8;
  252.  Res_outportb (baseport,0x0f);
  253.  Res_outportb (baseport+1,b1);
  254.  Res_outportb (baseport,0x0e);
  255.  Res_outportb (baseport+1,b2);
  256. }
  257. #else
  258. void mygotoxy (unsigned int posit) {
  259. unsigned char b1=posit & 0xFF;
  260. unsigned char b2=posit >> 8;
  261.  outportb (baseport,0x0f);    /* @0231 */
  262.  outportb (baseport+1,b1);
  263.  outportb (baseport,0x0e);
  264.  outportb (baseport+1,b2);
  265. }
  266. #endif
  267.  
  268. #if ((OVL_TYPE==1)&&(RESIDENT!=1))
  269. void movecursor(short x,short y) /* physical coordinates */
  270.  {
  271.   reg.h.ah=2;
  272.   reg.h.bh=0;
  273.   reg.h.dh=y-1;
  274.   reg.h.dl=x-1;
  275.   Res_int86(0x10,®,®);
  276. /*   mygotoxy (80*y + x - 81);  */
  277.    curpt=(char *)0xb8000000;
  278.    curpt+=((y-1)*160+(x-1)*2);
  279.  }
  280. #else
  281. void movecursor(short x,short y) /* physical coordinates */
  282.  {
  283.   reg.h.ah=2;
  284.   reg.h.bh=0;
  285.   reg.h.dh=y-1;
  286.   reg.h.dl=x-1;
  287.   int86(0x10,®,®);
  288. /*   mygotoxy (80*y + x - 81);  */
  289.    curpt=(char *)0xb8000000;
  290.    curpt+=((y-1)*160+(x-1)*2);
  291.  }
  292. #endif
  293. #endif             /* @0184 */
  294. void pgetputtext(p,xx1,yy1,xx2,yy2,buf)        /* @0182 */
  295. short p;    /* @0182 */
  296. short xx1;    /* @0182 */
  297. short yy1;    /* @0182 */
  298. short xx2;    /* @0182 */
  299. short yy2;    /* @0182 */
  300. char *buf;    /* @0182 */
  301.  {
  302.   char *pt;
  303.   short i,j;
  304. #if (OS_TYPE==4)          /* @0184 */
  305.   pt=videobuf;            /* @0184 */
  306. #else                     /* @0184 */
  307.   pt=(char *)0xb8000000;
  308. #endif                    /* @0184 */
  309.   pt+=((yy1-1)*160+(xx1-1)*2);
  310.   for (i=0;i<yy2-yy1+1;i++)
  311.    {
  312.     for (j=0;j<xx2-xx1+1;j++)
  313.       {
  314.     if (p==0)     /* gettext */
  315.       *buf=*pt;
  316.     else          /* puttext */
  317.       *pt=*buf;
  318.     buf++;
  319.     pt++;
  320.     if (p==0)
  321.       *buf=*pt;
  322.     else
  323.       *pt=*buf;
  324.     buf++;
  325.     pt++;
  326.       }
  327.     pt+=(160-2*(xx2-xx1+1));
  328.    }
  329.  }
  330. void pgotoxy(x,y)    /* @0182 */
  331. short x;    /* @0182 */
  332. short y;    /* @0182 */
  333.  {
  334.   pcurx=x+px1-1;
  335.   pcury=y+py1-1;
  336.   movecursor(pcurx,pcury);
  337.  }
  338. void pputch(c)        /* @0182 */
  339. char c;        /* @0182 */
  340.  {
  341.   char *pt;
  342.   pt=curpt;
  343.   if (c==0x0d)            /* @0079 */
  344.     pcurx=px1;            /* @0079 */
  345.   else                /* @0079 */
  346.     if (c==0x0a)        /* @0079 */
  347.       if (pcury==py2)        /* @0079 */
  348.     pcury=py1;        /* @0079 */
  349.       else             /* @0079 */
  350.     pcury++;        /* @0079 */
  351.     else            /* @0079 */
  352.       {                /* @0079 */
  353.     *pt=c;
  354.     pt++;
  355.     *pt=pattr;
  356.     if (pcurx==px2)
  357.       {
  358.         pcurx=px1;
  359.         if (pcury==py2)
  360.           pcury=py1;
  361.         else
  362.           pcury++;
  363.       }
  364.     else
  365.       pcurx++;
  366.       }                /* @0079 */
  367.   movecursor(pcurx,pcury);
  368.  }
  369. void pcprintf(s,dec)    /* @0159 */    /* @0182 */
  370. char *s;    /* @0182 */
  371. unsigned short dec;    /* @0182 */
  372.  {                    /* 1 */
  373.   unsigned  short len,min;        /* @0159 *//* @0160 */
  374.   while (*s != '\0')
  375.    {                                    /* 2 */
  376.     if (*s!='%')
  377.       pputch(*s);
  378.     else
  379.       {                                 /* 3 */
  380.        len=0;
  381.        min=0;        /* @0160 */
  382.        s++;
  383.        if (*s=='%')
  384.        pputch('%');
  385.        else
  386.     {                               /* 4 */
  387.      if (*s>48 && *s<54)
  388.       {
  389.        len=*s-48;
  390.        s++;
  391.       }
  392.      if (*s=='.')        /* @0160 */
  393.        {            /* @0160 */
  394.          s++;        /* @0160 */
  395.          if (*s>48 && *s<54)/* @0160 */
  396.            {        /* @0160 */
  397.          min=*s-48;    /* @0160 */
  398.          s++;        /* @0160 */
  399.            }        /* @0160 */
  400.          else        /* @0160 */
  401.            ;        /* @0160 */
  402.        }            /* @0160 */
  403.      if (*s=='u' || *s=='d')/* @0160 */
  404.          c_dec(dec,len,min);/* @0160 */
  405.      else ;
  406.     }                               /* 4 */
  407.       }
  408.      s++;
  409.     }
  410.  }
  411. void c_dec(de,le,mi)    /* @0159 *//* @0160 *//* @0182 */
  412. unsigned short de;    /* @0182 */
  413. unsigned short le;    /* @0182 */
  414. unsigned mi;        /* @0182 */
  415.  {
  416.   char d[5];
  417.   unsigned short i,new,old;    /* @0159 */
  418.   old=de;
  419.   for (i=0;i<5;i++)
  420.    {
  421.     new=old/10;
  422.     d[i]=old-new*10;
  423.     old=new;
  424.    }
  425.   for (i=5;i>0;i--)            /* @0159 */
  426.    if (d[i-1]==0 && i>mi)              /* @0159 *//* @0160 */
  427.      d[i-1]=' ';               /* @0159 */
  428.    else
  429.      break;
  430.   if (le==0)
  431.    le=i;                    /* @0160 */
  432.   for (i=le;i>0;i--)   /* @0159 */
  433.     if (d[i-1]==' ')   /* @0159 */
  434.       pputch(32);      /* @0159 */
  435.     else               /* @0159 */
  436.       pputch(d[i-1]+48);/* @0159 */
  437.  }
  438.  
  439.